home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Programming / Dialog Director 0.6 / Res Utils Examples / Copy Res File+.as < prev    next >
Encoding:
Text File  |  1996-12-06  |  1.3 KB  |  40 lines  |  [TEXT/ToyS]

  1. on run
  2.     set r to {}
  3.     set srcFile to choose file with prompt "Choose a res file:"
  4.     tell application "Finder" to get name of srcFile
  5.     set dstFile to new file with prompt "Copy to:" default name result & ".rsrc"
  6.     set r2 to 0
  7.     set rf to res open srcFile
  8.     try
  9.         try
  10.             res create dstFile creator type "RSED" file type "rsrc"
  11.         on error number errNum
  12.             if errNum = -48 then
  13.                 tell application "Finder" to delete dstFile
  14.                 res create dstFile creator type "RSED" file type "rsrc"
  15.             end if
  16.         end try
  17.         set r2 to res open dstFile with write permission
  18.         
  19.         set rTypesCount to res count types rf
  20.         repeat with i from 1 to rTypesCount
  21.             set rType to res get type rf index i
  22.             --tell application "Transcript" to «event miscEcho» rType --as string)
  23.             set rCount to res count rf type rType
  24.             set r to r & [rType, rCount]
  25.             repeat with j from 1 to rCount
  26.                 --tell application "Transcript" to «event miscEcho» " " & j
  27.                 res put r2 type rType id 1000 + j data (res get rf type rType index j)
  28.             end repeat
  29.             --tell application "Transcript" to «event miscEcho» return
  30.         end repeat
  31.         beep 1
  32.     on error errText number errNum from offendingObjectVariable
  33.         if r2 ≠ 0 then res close r2
  34.         res close rf
  35.         error errText number errNum from offendingObjectVariable
  36.     end try
  37.     res close r2
  38.     res close rf
  39.     r
  40. end run